<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	include("_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];
	
	$uid = chkstr(trim($_REQUEST['uid']));
	$aid = chkstr(trim($_REQUEST['aid']));
	$ac = chkstr(trim($_REQUEST['ac']));
	if(empty($uid)){
		echo erro("参数错误1");
	}
	if(!is_numeric($uid)){
		echo erro("参数错误2");
	}
	if(getNewsNums("kboy_user","uid=$uid") <1){
		echo erro("参数错误3");
	}

	if(empty($aid)){
		echo erro("参数错误4");
	}
	if(!is_numeric($aid)){
		echo erro("参数错误5");
	}
	if(getNewsNums("kboy_forum_album","uid=$uid and id=$aid") <1){
		echo erro("参数错误6");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的相册_社区_<?= $web_titles ?></title>
<meta name="Keywords" content="我的相册,社区,<?= $web_keywords ?>" />
<meta name="Description" content="<?= $web_description ?>" />
<link rel="stylesheet" href="css/common.css"/>
<link rel="stylesheet" href="css/sq.css"/>
<script type="text/javascript" src="js/baidutongji.js"></script>
<link rel="stylesheet" type="text/css" href="css/webuploader.css" />
</head>
<body>
    <!--top-bar begin-->
	<? include("_include.top.topbar.php") ?>
    <!--top-bar end-->
    <!--header begin-->
	<? include("_include.top.navbar.php") ?>
    <!--header end-->
    <!--banner begin-->
	<? include("_include.forum.banners.php") ?>
    <!--banner end-->
    <!--活动 begin-->
    <div class="sq-wrap">
		<? include("_include.forum.title.php") ?>
        <div class="sq-bd">
			<? include("_include.forum.topnav.php") ?>
        <div class="sq-bd-con">
            <div class="sq-bd-l">
                <div class="sq-photo-wrap">
                    <div class="Record_main_p">
                        <div class="Seconavi">
                            <a href="forum_photo_pic.php?uid=<?=$uid?>&aid=<?=$aid?>">返回我的相册</a> | <a href="javascript:void(0);" id="upload-images">上传更多照片</a>
                            <span class="num-r">已有<i><?=getNewsNums("kboy_forum_pic","uid=$uid and aid=$aid")?></i>张照片</span>
                        </div>
						<form name="picform" id="picform" method="post" action="forum_photo_picaddsave.php?action=edit">
						<input type="hidden" name="aid" value="<?=$aid?>" />
                        <div class="sq-p-editor">
						
						
						<?php
								if($ac == "upload"){
									$news_sql = "select * from kboy_forum_pic where uid=$kboy_userid and aid=$aid and photo_isedit=0 order by id desc";
								}else{
									$news_sql = "select * from kboy_forum_pic where uid=$kboy_userid and aid=$aid order by id desc";
								}
								$news_rows = mysql_query($news_sql);
								while($news_rs = mysql_fetch_array($news_rows)){
						?>
						
                            <div class="p-editor">
                                <div class="editor-l">
                                    <div class="pic">
										<input type="hidden" name="picid[]" value="<?=$news_rs['id']?>" />
                                        <img src="<?=$news_rs['photo_pic']?>" width="130" height="70" alt=""/>
                                    </div>
                                    <div class="set-label">
                                        <span><label>
										<?php
												if($news_rs['photo_face'] == 1){
										?>
										<input type="radio" name="photo_face" value="<?=$news_rs['id']?>" checked="checked">
										<?php
												}else{
										?>
										<input type="radio" name="photo_face" value="<?=$news_rs['id']?>">
										<?php
												}
										?>
										
										设为封面</label></span>
                                        <span><!--<label>删除</label>--></span>
                                    </div>
                                </div>
                                <div class="editor-r">
                                    <div class="title">编辑标题</div>
                                    <textarea name="photo_title[]"><?=$news_rs['photo_title']?></textarea>
                                </div>
                            </div>
						<?php
								}
						?>	
                            <div class="p-editor-operate"><input type="submit" name="btn" value="保存编辑" /><a href="forum_photo_pic.php?uid=<?=$uid?>&aid=<?=$aid?>">返回相册</a></div>
                        </div>
						</form>
                    </div>
                </div>
            </div>
			
			
			
				<? include("_include.forum.right.php") ?>
			
			
			
        </div>
    </div>
</div>
    <!--foot begin-->
	<? include("_include.bottom.footbar.php") ?>
    <!--foot begin-->
    <!--左侧悬浮 begin-->
	<? include("_include.bottom.leftbar.php") ?>
    <!--左侧悬浮 end-->
    <!--右侧悬浮导航 begin-->
	<? include("_include.bottom.rightbar.php") ?>
    <!--右侧悬浮导航 end-->
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/sq.js"></script>
	<link rel="stylesheet" href="SunbeamEditor/themes/default/default.css" />
	<script charset="utf-8" src="SunbeamEditor/kindeditor.js"></script>
	<script charset="utf-8" src="SunbeamEditor/lang/zh_CN.js"></script>
    <script type="text/javascript">
		
	KindEditor.ready(function(K) {
		
		/////   点击上传图片
		var editor = K.editor({
			allowFileManager : false
		});
		K('#upload-images').click(function() {
			editor.loadPlugin('multiimage', function() {
				console.log(editor)
				editor.plugin.multiImageDialog({
					clickFn : function(urlList) {
						K.each(urlList, function(i, data) {
						
							$.ajax({ 
								url:'forum_photo_picaddsave.php', 
								type:'post',
								dataType:'html',
								data:'action=add&aid=<?=$aid?>&photo_pic=' + data.url + '&date='+new Date(),
								error: function(){
									alert('Error loading document'); 
								},success: function(msg){
									alert(msg);
								} 
							}); 
							
						
						});
						window.location.href='forum_photo_picedit.php?uid=<?=$uid?>&aid=<?=$aid?>&ac=upload';
						editor.hideDialog();
					}
				});
			});
		});
	});
    </script>
</body>
</html>

